package com.Work;

import com.alibaba.fastjson2.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Exam03 {
    public static void main(String[] args) {
        File file = new File("days9.15/src/txtpack/json.txt");
        try(FileReader reader = new FileReader(file)){
            char[] chars = new char[150];
            int size;
            while ((size = reader.read()) != -1) {
                reader.read(chars,0,size);
            }
            System.out.println(chars);
            System.out.println("上边为chars数组");
            String student = new String(chars);
            Student stu = JSON.parseObject(student,Student.class);
            System.out.println(stu);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

@Data
@AllArgsConstructor
@NoArgsConstructor
class Student {

    private int id;
    private String name;
    private int age;
    private String password;
    private String[] hobby;

}